class Solution 
{
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) 
    {
        vector<vector<string>> ret;
        unordered_map<string, vector<string>> mp;

        for (size_t i = 0; i < strs.size(); i++)
        { 
            string key = strs[i];
            sort(key.begin(), key.end());
            mp[key].emplace_back(strs[i]);
        }

        unordered_map<string, vector<string>>::iterator iter = mp.begin();
        for (; iter != mp.end(); iter++)
        {
            ret.emplace_back(iter->second);
        }
        return ret;
    }
};